import json

import pytest

from api.employee_Api import Employee
from api.login_Api import LoginApi
from data import login_data

@pytest.fixture
def token_fixture():
    emp = Employee()
    resp = emp.login("/admin/employee/login",json.dumps(login_data))
    token = resp.json().get("data").get("token")
    # print(token)
    headers = {"Content-Type": "application/json", "token":token}
    yield headers
    pass
@pytest.fixture
def log_token_fixture():
    login = LoginApi()
    res = login.login({"username": "user123", "password": "user123"})
    token = res.json().get("data").get("token")
    print(token)
    headers = {"X-Litemall-Token":token}
    yield headers
    pass

@pytest.fixture(scope="class")
def class_fixture():
    print("这是类级别的夹具前")
    yield
    print("这是类级别的夹具后")

@pytest.fixture
def fun_fixture():
    print("这是函数级别的夹具前")
    yield
    print("这是函数级别的夹具后")